﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PhotoResizer
{
    public partial class Feedback : Form
    {
        public Feedback()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex < 0 && comboBox1.SelectedIndex > comboBox1.Items.Count )
            {
                MessageBox.Show("Please select a Type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBox1.Text == "")
            {
                MessageBox.Show("Please type some feedback", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("Please type your name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBox3.Text == "")
            {
                MessageBox.Show("Please type your email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //email name validation not done
            }
            else
            {
                button1.Enabled = false;
                this.Cursor = Cursors.WaitCursor;

                PRWebService.Service a = new PRWebService.Service();
                string status = a.SendFeedBack(comboBox1.SelectedText, textBox2.Text, textBox3.Text, textBox1.Text);
                if (status == "Successful")
                {
                    MessageBox.Show("Feedback Sent. Thanks for taking time to give feedback.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Cannot send feedback. Please send your feedback on the website.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                this.Cursor = Cursors.Default;
                this.Hide();
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 2000)
            {
                MessageBox.Show("Max Char Count Limit reached", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                label4.Text = (2000 - Convert.ToInt32(textBox1.Text.Length)).ToString();
            }
        }
    }
}
